package com.servlet01;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

/**
 * @author wzm
 * @create 2023-09-19 10:42
 * project_name:javaweb2308
 */
//@WebServlet(urlPatterns = "/demo1",loadOnStartup = 1)  //配置访问Servlet的路径
@WebServlet("/demo1")
public class HelloServlet01 implements Servlet {
    private ServletConfig config;

    //构造方法
    public HelloServlet01() {
        System.out.println("构造方法执行了");
    }

    @Override
    public void init(ServletConfig config) throws ServletException {
        this.config=config;
        System.out.println("初始化...");
    }

    //返回Servlet的配置信息
    @Override
    public ServletConfig getServletConfig() {
        return this.config;
    }

    //servlet提供服务的方法
    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        System.out.println("HelloWorld!!");
        System.out.println("Service执行了");
    }

    //返回和Servlet相关的信息
    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("销毁");

    }
}


